package com.qdaily.ui.net;

import android.text.TextUtils;
import com.qdaily.supportlibrary.util.NetUtil;
import com.qdaily.ui.util.QDTestServerSetHelper;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

/**
 * 网络参数配置文件
 * Created with IntelliJ IDEA.
 * User: Felix
 * Date: 3/30/15
 * Time: 13:47
 * QQ:74104
 * Email:lovejiuwei@gmail.com
 */
public class NetConfigs {

    private static String mCookie = "";// 临时添加的，底层网络封装的太死了，只能这么做。
    /**
     * 服务接口HOST地址
     */
    public final static String API_HOST = QDTestServerSetHelper.getServerIp();
    /**
     * HTTP返回码
     */
    public final static int HTTP_RESPONSE_200 = 200;

    /**
     * *****************************************************************************
     * 业务逻辑开始
     * 注：路径中最后的0.json中的0代表第一页，访问其他页将返回的json中的last_time替换0.
     * ******************************************************************************
     */

    public static void getCookie(String cookie) {
        mCookie = cookie;
    }

    public static void removeCookie() {
        mCookie = "";
        mCookie = null;
    }

    /**
     * 用户退出（delete）
     */
    public static final String URL_SING_OUT = API_HOST + "users/sign_out";
    /**
     * 修改密码
     */
    public static final String URL_CHANGE_PASSWORD = API_HOST + "users";

    /**
     * ********************************GET**************************************
     */

    /**
     * 首頁
     */
    public static class RequestHomesDada implements NetUtil.NetParams {

        private long mLastTime = 0;

        public RequestHomesDada(long mLastTime) {
            this.mLastTime = mLastTime;
        }

        public long getmLastTime() {
            return mLastTime;
        }

        /**
         * http://42.121.104.18:10002/app/homes/index/0.json
         */
        public final static String SUFFIX_URL = API_HOST + "app/homes/index/%s.json";

        @Override
        public Map<String, Object> getPostNetParams() {
            return null;
        }

        @Override
        public Map<String, Object> getHeaderNetParams() {
            return getHeader();
        }

        @Override
        public String getUrl() {
            return String.format(SUFFIX_URL, mLastTime);
        }

    }

    /**
     * 主页，侧边栏
     */
    public static class RequestHomeLeftSidebar implements NetUtil.NetParams {
        /**
         * http://42.121.104.18:10002/app/homes/left_sidebar.json
         */
        public final static String SUFFIX_URL = API_HOST + "app/homes/left_sidebar.json";

        @Override
        public Map<String, Object> getPostNetParams() {
            return null;
        }

        @Override
        public Map<String, Object> getHeaderNetParams() {
            return getHeader();
        }

        @Override
        public String getUrl() {
            return SUFFIX_URL;
        }
    }

    /**
     * 主页，侧边栏，雷达图
     */
    public static class RequestRadar implements NetUtil.NetParams {
        /**
         * http://42.121.104.18:10002/app/users/radar
         */
        public final static String SUFFIX_URL = API_HOST + "app/users/radar";

        @Override
        public Map<String, Object> getPostNetParams() {
            return null;
        }

        @Override
        public Map<String, Object> getHeaderNetParams() {
            return getHeader();
        }

        @Override
        public String getUrl() {
            return SUFFIX_URL;
        }
    }

    /**
     * 主页，侧边栏，雷达图，点击某个标签跳转列表。
     */
    public static class RequestRadarList implements NetUtil.NetParams {
        public final static String SUFFIX_URL = API_HOST + "app/radars/index/%s/%s.json";
        /**
         * http://42.121.104.18:10002/app/radars/index/2/0.json
         */
        private int mCategorieId;

        private long mLastTime;

        public RequestRadarList(int categorieId, long last_time) {
            this.mCategorieId = categorieId;
            this.mLastTime = last_time;
        }

        public int getmCategorieId() {
            return mCategorieId;
        }

        public long getmLastTime() {
            return mLastTime;
        }

        @Override
        public Map<String, Object> getPostNetParams() {
            return null;
        }

        @Override
        public Map<String, Object> getHeaderNetParams() {
            return getHeader();
        }

        @Override
        public String getUrl() {
            return  String.format(SUFFIX_URL, mCategorieId, mLastTime);
        }
    }

    /**
     * 分类下文章列表
     */
    public static class RequestCategoriesArticles implements NetUtil.NetParams {
        /**
         * 分类下文章列表 http://42.121.104.18:10002/app/categories/index/17/0.json
         */
        public final static String SUFFIX_URL = API_HOST + "app/categories/index/%s/%s.json";

        private int mCategorieId;
        private long mLastTime;

        public RequestCategoriesArticles(int categorieId, long last_time) {
            this.mCategorieId = categorieId;
            this.mLastTime = last_time;
        }

        public int getmCategorieId() {
            return mCategorieId;
        }

        public long getmLastTime() {
            return mLastTime;
        }

        @Override
        public Map<String, Object> getPostNetParams() {
            return null;
        }

        @Override
        public Map<String, Object> getHeaderNetParams() {
            return getHeader();
        }

        @Override
        public String getUrl() {
            return String.format(SUFFIX_URL, mCategorieId, mLastTime);
        }
    }

    /**
     * 标签下文章列表
     */
    public static class RequestTagsArticles implements NetUtil.NetParams {
        /**
         * 标签下文章列表 http://42.121.104.18:10002/app/tags/index/1615/0.json
         */
        public final static String SUFFIX_URL = API_HOST + "app/tags/index/%s/%s.json";

        private int mTagsId;
        private long mLastTime;

        public RequestTagsArticles(int tagsId, long last_time) {
            this.mTagsId = tagsId;
            this.mLastTime = last_time;
        }

        public long getmLastTime() {
            return mLastTime;
        }

        @Override
        public Map<String, Object> getPostNetParams() {
            return null;
        }

        @Override
        public Map<String, Object> getHeaderNetParams() {
            return getHeader();
        }

        @Override
        public String getUrl() {
            return String.format(SUFFIX_URL, mTagsId, mLastTime);
        }
    }

    /**
     * 文章详情，css/js/imge预先用webview缓存到本地。
     */
    public static class RequestArticleDetail implements NetUtil.NetParams {
        /**
         * 文章详情 http://42.121.104.18:10002/app/articles/detail/591.json
         */
        public final static String SUFFIX_URL = API_HOST + "app/articles/detail/%s.json";

        private int mArticleId;

        public RequestArticleDetail(int articleId) {
            this.mArticleId = articleId;
        }

        @Override
        public Map<String, Object> getPostNetParams() {
            return null;
        }

        @Override
        public Map<String, Object> getHeaderNetParams() {
            return getHeader();
        }

        @Override
        public String getUrl() {
            return String.format(SUFFIX_URL, mArticleId);
        }
    }

    /**
     * 文章详情，与RequestArticleDetail对应，这个是一些相关信息，比如作者等。
     */
    public static class RequestArticleInfo implements NetUtil.NetParams {
        /**
         * 文章详情 http://42.121.104.18:10002/app/articles/info/591.json
         */
        public final static String SUFFIX_URL = API_HOST + "app/articles/info/%s.json";

        private int mArticleId;

        public RequestArticleInfo(int articleId) {
            this.mArticleId = articleId;
        }

        @Override
        public Map<String, Object> getPostNetParams() {
            return null;
        }

        @Override
        public Map<String, Object> getHeaderNetParams() {
            return getHeader();
        }

        @Override
        public String getUrl() {
            return String.format(SUFFIX_URL, mArticleId);
        }
    }

    /**
     * 问卷列表
     */
    public static class RequestQuestionnaireLists implements NetUtil.NetParams {
        /**
         * 问卷列表 http://42.121.104.18:10002/app/papers/index/0.json
         */
        public final static String SUFFIX_URL = API_HOST + "app/papers/index/%s.json";

        private long mLastTime;

        public RequestQuestionnaireLists(long lastTime) {
            this.mLastTime = lastTime;
        }

        public long getmLastTime() {
            return mLastTime;
        }

        @Override
        public Map<String, Object> getPostNetParams() {
            return null;
        }

        @Override
        public Map<String, Object> getHeaderNetParams() {
            return getHeader();
        }

        @Override
        public String getUrl() {
            return String.format(SUFFIX_URL, mLastTime);
        }
    }

    /**
     * 问卷详情
     */
    public static class RequestQuestionnaireDetail implements NetUtil.NetParams {
        /**
         * 问卷详情 http://42.121.104.18:10002/app/papers/detail/91.json
         */
        public final static String SUFFIX_URL = API_HOST + "app/papers/detail/%s.json";

        private int mPaperId;

        public RequestQuestionnaireDetail(int paperId) {
            this.mPaperId = paperId;
        }

        @Override
        public Map<String, Object> getPostNetParams() {
            return null;
        }

        @Override
        public Map<String, Object> getHeaderNetParams() {
            return getHeader();
        }

        @Override
        public String getUrl() {
            return String.format(SUFFIX_URL, mPaperId);
        }
    }


    /**
     * 用户问卷详情
     */
    public static class RequestUserQuestionDetail implements NetUtil.NetParams {
        /**
         * 问卷详情 http://42.121.104.18:10002/app/papers/detail/91.json
         */
        public final static String SUFFIX_URL = API_HOST + "app/users/paper_detail?paper_id=%s";

        private int mPaperId;

        public RequestUserQuestionDetail(int paperId) {
            this.mPaperId = paperId;
        }

        @Override
        public Map<String, Object> getPostNetParams() {
            return null;
        }

        @Override
        public Map<String, Object> getHeaderNetParams() {
            return getHeader();
        }

        @Override
        public String getUrl() {
            return String.format(SUFFIX_URL, mPaperId);
        }
    }

    /**
     * Mob详情
     */
    public static class RequestMobDetail implements NetUtil.NetParams {
        /**
         * Mob详情 http://42.121.104.18:10002/app/mobs/detail/91.json
         */
        public final static String SUFFIX_URL = API_HOST + "app/papers/detail/%s.json";

        private int mMobId;

        public RequestMobDetail(int mobId) {
            this.mMobId = mobId;
        }

        @Override
        public Map<String, Object> getPostNetParams() {
            return null;
        }

        @Override
        public Map<String, Object> getHeaderNetParams() {
            return getHeader();
        }

        @Override
        public String getUrl() {
            return String.format(SUFFIX_URL, mMobId);
        }
    }

    /**
     * Mob Options
     */
    public static class RequestMobOptions implements NetUtil.NetParams {
        /**
         * Mob options http://42.121.104.18:10002/app/options/index/91/0.json
         */
        public final static String SUFFIX_URL = API_HOST + "app/options/index/%s/%s.json";

        private int mMobId;
        private long mLastTime;

        public RequestMobOptions(int mobId, long lastTime) {
            this.mMobId = mobId;
            this.mLastTime = lastTime;
        }

        public long getmLastTime() {
            return mLastTime;
        }

        @Override
        public Map<String, Object> getPostNetParams() {
            return null;
        }

        @Override
        public Map<String, Object> getHeaderNetParams() {
            return getHeader();
        }

        @Override
        public String getUrl() {
            return String.format(SUFFIX_URL, mMobId, mLastTime);
        }
    }

    /**
     * 问卷评论
     */
    public static class RequestQuestionnaireComments implements NetUtil.NetParams {
        /**
         * 问卷评论 http://42.121.104.18:10002/app/comments/index/paper/86/0.json
         */
        public final static String SUFFIX_URL = API_HOST + "app/comments/index/paper/%s/%s.json";

        private int mPaperId;
        private long mLastTime;

        public RequestQuestionnaireComments(int paperId, long lastTime) {
            this.mPaperId = paperId;
            this.mLastTime = lastTime;
        }

        @Override
        public Map<String, Object> getPostNetParams() {
            return null;
        }

        @Override
        public Map<String, Object> getHeaderNetParams() {
            return getHeader();
        }

        @Override
        public String getUrl() {
            return String.format(SUFFIX_URL, mPaperId, mLastTime);
        }
    }

    /**
     * 文章评论
     */
    public static class RequestArticleComments implements NetUtil.NetParams {
        /**
         * 文章评论 http://42.121.104.18:10002/app/comments/index/article/2081/0.json
         */
        public final static String SUFFIX_URL = API_HOST + "app/comments/index/article/%s/%s.json";

        private int mArticleId;
        private long mLastTime;

        public RequestArticleComments(int articleId, long lastTime) {
            this.mArticleId = articleId;
            this.mLastTime = lastTime;
        }

        @Override
        public Map<String, Object> getPostNetParams() {
            return null;
        }

        @Override
        public Map<String, Object> getHeaderNetParams() {
            return getHeader();
        }

        @Override
        public String getUrl() {
            return String.format(SUFFIX_URL, mArticleId, mLastTime);
        }
    }

    /**
     * 用户设置
     */
    public static class RequestUserSettings implements NetUtil.NetParams {
        /**
         * http://42.121.104.18:10002/app/users/setting
         */
        public final static String SUFFIX_URL = API_HOST + "app/users/setting";

        public RequestUserSettings() {
        }

        @Override
        public Map<String, Object> getPostNetParams() {
            return null;
        }

        @Override
        public Map<String, Object> getHeaderNetParams() {
            return getHeader();
        }

        @Override
        public String getUrl() {
            return String.format(SUFFIX_URL);
        }
    }

    /**
     * 我赞过的（GET）
     */
    public static class RequestMyPraises implements NetUtil.NetParams {
        /**
         * http://42.121.104.18:10002/app/users/my_praises
         */
        public final static String SUFFIX_URL = API_HOST + "app/users/my_praises";
        private int mLastTime;

        public RequestMyPraises(int lastTime) {
            this.mLastTime = lastTime;
        }

        @Override
        public Map<String, Object> getPostNetParams() {
            Map<String, Object> map = new HashMap<String, Object>();
            map.put("last_time", mLastTime);
            return map;
        }

        @Override
        public Map<String, Object> getHeaderNetParams() {
            return getHeader();
        }

        @Override
        public String getUrl() {
            return String.format(SUFFIX_URL);
        }
    }


    /**
     * 赞过我的（GET）
     */
    public static class RequestPraisesOnMy implements NetUtil.NetParams {
        /**
         * http://42.121.104.18:10002/app/users/praise_on_my
         */
        public final static String SUFFIX_URL = API_HOST + "app/users/praise_on_my";
        private int mLastTime;

        public RequestPraisesOnMy(int lastTime) {
            this.mLastTime = lastTime;
        }

        public int getLastTime() {
            return mLastTime;
        }

        @Override
        public Map<String, Object> getPostNetParams() {
            Map<String, Object> map = new HashMap<String, Object>();
            map.put("last_time", mLastTime);
            return map;
        }

        @Override
        public Map<String, Object> getHeaderNetParams() {
            return getHeader();
        }

        @Override
        public String getUrl() {
            return String.format(SUFFIX_URL);
        }
    }

    /**
     * 我的评论（GET）
     */
    public static class RequestMyComments implements NetUtil.NetParams {
        /**
         * http://42.121.104.18:10002/app/users/my_comments
         */
        public final static String SUFFIX_URL = API_HOST + "app/users/my_comments";
        private int mLastTime;

        public RequestMyComments(int lastTime) {
            this.mLastTime = lastTime;
        }

        public int getLastTime() {
            return mLastTime;
        }

        @Override
        public Map<String, Object> getPostNetParams() {
            Map<String, Object> map = new HashMap<String, Object>();
            map.put("last_time", mLastTime);
            return map;
        }

        @Override
        public Map<String, Object> getHeaderNetParams() {
            return getHeader();
        }

        @Override
        public String getUrl() {
            return String.format(SUFFIX_URL);
        }
    }

    /**
     * 评论过我的（GET）
     */
    public static class RequestCommentOnMy implements NetUtil.NetParams {
        /**
         * http://42.121.104.18:10002/app/users/comment_on_my
         */
        public final static String SUFFIX_URL = API_HOST + "app/users/comment_on_my";
        private int mLastTime;

        public RequestCommentOnMy(int lastTime) {
            this.mLastTime = lastTime;
        }

        public int getLastTime() {
            return mLastTime;
        }

        @Override
        public Map<String, Object> getPostNetParams() {
            Map<String, Object> map = new HashMap<String, Object>();
            map.put("last_time", mLastTime);
            return map;
        }

        @Override
        public Map<String, Object> getHeaderNetParams() {
            return getHeader();
        }

        @Override
        public String getUrl() {
            return String.format(SUFFIX_URL);
        }
    }

    /**
     * 用户中心（GET）
     */
    public static class RequestUserCenter implements NetUtil.NetParams {
        /**
         * http://42.121.104.18:10002/app/users/center
         */
        public final static String SUFFIX_URL = API_HOST + "app/users/center";

        public RequestUserCenter() {
        }

        @Override
        public Map<String, Object> getPostNetParams() {
            Map<String, Object> map = new HashMap<String, Object>();
            return map;
        }

        @Override
        public Map<String, Object> getHeaderNetParams() {
            return getHeader();
        }

        @Override
        public String getUrl() {
            return String.format(SUFFIX_URL);
        }
    }

    /************************************POST***************************************/

    /**
     * 发表评论（post）
     * 注释：comment_type= article || paper , id=文章id || 问卷id , parent_id = 父评论id，如果没有父评论传0
     */
    public static class RequestSendComment implements NetUtil.NetParams {
        /**
         * 发表评论（post）     http://42.121.104.18:10002/app/comments/create_comment
         */
        public final static String SUFFIX_URL = API_HOST + "app/comments/create_comment";

        private String commentType;
        private String content;
        private int typeId;
        private int commentId;

        public RequestSendComment(String commentType, String content, int typeId, int parent_id) {
            this.commentType = commentType;
            this.content = content;
            this.typeId = typeId;
            this.commentId = parent_id;
        }

        public String getCommentType() {
            return commentType;
        }

        public void setCommentType(String commentType) {
            this.commentType = commentType;
        }

        public String getContent() {
            return content;
        }

        public void setContent(String content) {
            this.content = content;
        }

        public int getTypeId() {
            return typeId;
        }

        public void setTypeId(int typeId) {
            this.typeId = typeId;
        }

        public int getCommentId() {
            return commentId;
        }

        public void setCommentId(int commentId) {
            this.commentId = commentId;
        }

        @Override
        public Map<String, Object> getPostNetParams() {
            Map<String, Object> map = new HashMap<String, Object>();
            map.put("comment_type", commentType);
            map.put("content", content);
            map.put("id", typeId);
            map.put("parent_id", commentId);
            return map;
        }

        @Override
        public Map<String, Object> getHeaderNetParams() {
            return getHeader();
        }

        @Override
        public String getUrl() {
            return String.format(SUFFIX_URL);
        }
    }

    /**
     * 赞（POST）
     * 注释：praise_type= article || paper || comment , id=文章id || 问卷id || 评论id
     * genre = 1（赞） || 2（取消赞）
     */
    public static class RequestLikeIt implements NetUtil.NetParams {
        /**
         * 赞 http://42.121.104.18:10002/app/praises/create_praise
         */
        public final static String SUFFIX_URL = API_HOST + "app/praises/create_praise";

        private String praise_type;
        private int typeId;
        private int genre;

        public RequestLikeIt(String praise_type, int typeId, int genre) {
            this.praise_type = praise_type;
            this.typeId = typeId;
            this.genre = genre;
        }

        public String getPraise_type() {
            return praise_type;
        }

        public void setPraise_type(String praise_type) {
            this.praise_type = praise_type;
        }

        public int getTypeId() {
            return typeId;
        }

        public void setTypeId(int typeId) {
            this.typeId = typeId;
        }

        public int getGenre() {
            return genre;
        }

        public void setGenre(int genre) {
            this.genre = genre;
        }

        @Override
        public Map<String, Object> getPostNetParams() {
            Map<String, Object> map = new HashMap<String, Object>();
            map.put("praise_type", praise_type);
            map.put("id", typeId);
            map.put("genre", genre);
            return map;
        }

        @Override
        public Map<String, Object> getHeaderNetParams() {
            return getHeader();
        }

        @Override
        public String getUrl() {
            return String.format(SUFFIX_URL);
        }
    }

    /**
     * 用户登陆（POST）
     */
    public static class RequestSignin implements NetUtil.NetParams {
        /**
         * http://42.121.104.18:10002/app/users/sign_in
         */
        public final static String SUFFIX_URL = API_HOST + "users/sign_in";

        private String email;
        private String password;

        public RequestSignin(String email, String password) {
            this.email = email;
            this.password = password;
        }

        @Override
        public Map<String, Object> getPostNetParams() {
            Map<String, Object> map = new HashMap<String, Object>();
            map.put("user[email]", email);
            map.put("user[password]", password);
            return map;
        }

        @Override
        public Map<String, Object> getHeaderNetParams() {
            return getHeader();
        }

        @Override
        public String getUrl() {
            return String.format(SUFFIX_URL);
        }
    }

    /**
     * 社交登陆與绑定（POST）
     * 注释：private_token（用户token，社交绑定时有这个参数）；type（社交平台类型：1微博，2qq，3微信，4twitter）；uid（社交id）；token（社交平台token）
     */
    public static class RequestSocialAction implements NetUtil.NetParams {
        /**
         * http://42.121.104.18:10002/app/users/social_sign_in
         */
        public final static String SUFFIX_URL = API_HOST + "users/social_sign_in";
        private String uid;
        private String token;
        private String username;
        private String face;
        private int socialType;

        public RequestSocialAction(String uid, String token, String username, String face, int socialType) {
            this.uid = uid;
            this.token = token;
            this.username = username;
            this.face = face;
            this.socialType = socialType;
        }

        @Override
        public Map<String, Object> getPostNetParams() {
            Map<String, Object> map = new HashMap<String, Object>();
            map.put("token", token);
            map.put("username", username);
            map.put("face", face);
            map.put("type", socialType);
            map.put("uid", uid);
            return map;
        }

        @Override
        public Map<String, Object> getHeaderNetParams() {
            return getHeader();
        }

        @Override
        public String getUrl() {
            return String.format(SUFFIX_URL);
        }
    }

    /**
     * 用户注册 第一步验证（POST）
     */
    public static class RequestRegisterFirstStep implements NetUtil.NetParams {
        /**
         * http://42.121.104.18:10002/users/verify
         */
        public final static String SUFFIX_URL = API_HOST + "users/verify";

        private String email;
        private String password;

        public RequestRegisterFirstStep(String email, String password) {
            this.email = email;
            this.password = password;
        }

        @Override
        public Map<String, Object> getPostNetParams() {
            Map<String, Object> map = new HashMap<String, Object>();
            map.put("user[email]", email);
            map.put("user[password]", password);
            map.put("user[password_confirmation]", password);
            return map;
        }

        @Override
        public Map<String, Object> getHeaderNetParams() {
            return null;
        }

        @Override
        public String getUrl() {
            return String.format(SUFFIX_URL);
        }
    }

    /**
     * 用户注册（POST）
     */
    public static class RequestRegister implements NetUtil.NetParamsWithUpload {
        /**
         * http://42.121.104.18:10002/app/users/sign_up
         */
        public final static String SUFFIX_URL = API_HOST + "users";
        private String email;
        private String password;
        private File mFace;
        private String mDescription;
        private String mUsername;

        private final String faceFiledName = "user[face]";

        public RequestRegister(String email, String password, String description, String username, File face) {
            this.email = email;
            this.password = password;
            this.mFace = face;
            this.mDescription = description;
            this.mUsername = username;
        }

        @Override
        public Map<String, Object> getPostNetParams() {
            Map<String, Object> map = new HashMap<String, Object>();
            map.put("user[email]", email);
            map.put("user[password]", password);
            map.put("user[password_confirmation]", password);
            map.put("user[description]", mDescription);
            map.put("user[username]", mUsername);
            return map;
        }

        @Override
        public Map<String, Object> getHeaderNetParams() {
            return null;
        }

        @Override
        public String getUrl() {
            return String.format(SUFFIX_URL);
        }

        @Override
        public String getUploadFieldName() {
            return faceFiledName;
        }

        @Override
        public File getUploadFile() {
            return mFace;
        }
    }

    /**
     * 找回密码（POST）
     */
    public static class RequestfindPassword implements NetUtil.NetParams {
        /**
         * http://42.121.104.18:10002/app/users/find_password
         */
        public final static String SUFFIX_URL = API_HOST + "app/users/find_password";

        private String email;

        public RequestfindPassword(String email) {
            this.email = email;
        }

        @Override
        public Map<String, Object> getPostNetParams() {
            Map<String, Object> map = new HashMap<String, Object>();
            map.put("user[email]", email);
            return map;
        }

        @Override
        public Map<String, Object> getHeaderNetParams() {
            return getHeader();
        }

        @Override
        public String getUrl() {
            return String.format(SUFFIX_URL);
        }
    }

    /**
     * 修改个人信息（POST）
     */
    public static class RequestUpdatePersonalInformation implements NetUtil.NetParamsWithUpload {
        /**
         * http://42.121.104.18:10002/app/users/update_my_personal_information
         */
        public final static String SUFFIX_URL = API_HOST + "app/users/update_my_personal_information";

        private String userName;
        private String description;
        private String email;
        private File face;

        public RequestUpdatePersonalInformation(File face, String userName, String description, String email) {
            this.face = face;
            this.userName = userName;
            this.description = description;
            this.email = email;
        }

        @Override
        public Map<String, Object> getPostNetParams() {
            Map<String, Object> map = new HashMap<String, Object>();
            if (!TextUtils.isEmpty(userName)) {
                map.put("user[username]", userName);
            }
            if (!TextUtils.isEmpty(description)) {
                map.put("user[description]", description);
            }
            if (!TextUtils.isEmpty(email)) {
                map.put("user[email]", email);
            }
            return map;
        }

        @Override
        public Map<String, Object> getHeaderNetParams() {
            return getHeader();
        }

        @Override
        public String getUrl() {
            return String.format(SUFFIX_URL);
        }

        @Override
        public String getUploadFieldName() {
            if (null != face) {
                return "user[face]";
            }
            return "";
        }

        @Override
        public File getUploadFile() {
            return null != face ? face : null;
        }
    }

    /**
     * 我的生活研究所（POST）
     */
    public static class RequestMyLifeInstitute implements NetUtil.NetParams {
        /**
         * http://42.121.104.18:10002/app/users/papers
         */
        public final static String SUFFIX_URL = API_HOST + "app/users/papers";
        private int mLastTime;

        public int getLastTime() {
            return mLastTime;
        }

        public RequestMyLifeInstitute(int lastTime) {
            this.mLastTime = lastTime;
        }

        @Override
        public Map<String, Object> getPostNetParams() {
            Map<String, Object> map = new HashMap<String, Object>();
            map.put("last_time", mLastTime);
            return map;
        }

        @Override
        public Map<String, Object> getHeaderNetParams() {
            return getHeader();
        }

        @Override
        public String getUrl() {
            return String.format(SUFFIX_URL);
        }
    }

    /**
     * Mob上传选项（POST）
     */
    public static class RequestUploadMob implements NetUtil.NetParamsWithUpload {
        /**
         * http://42.121.104.18:10002/app/options/create_moboption
         */
        public final static String SUFFIX_URL = API_HOST + "app/options/mob_create_option";
        private String mTitle;
        private int mParperId;
        private File mImageFile;

        public RequestUploadMob(int paper_id, String title, File image) {
            this.mParperId = paper_id;
            this.mTitle = title;
            this.mImageFile = image;
        }

        @Override
        public Map<String, Object> getPostNetParams() {
            Map<String, Object> map = new HashMap<String, Object>();
            map.put("paper_id", mParperId);
            map.put("title", mTitle);
            return map;
        }

        @Override
        public Map<String, Object> getHeaderNetParams() {
            return getHeader();
        }

        @Override
        public String getUrl() {
            return String.format(SUFFIX_URL);
        }

        @Override
        public String getUploadFieldName() {
            return "image";
        }

        @Override
        public File getUploadFile() {
            return mImageFile;
        }
    }

    /**
     * 用户反馈（POST）
     */
    public static class RequestFeedbacks implements NetUtil.NetParams {
        /**
         * http://42.121.104.18:10002/app/feedbacks
         */
        public final static String SUFFIX_URL = API_HOST + "app/feedbacks";
        private String mFeedbackTitle;
        private String mFeedbackContent;

        public RequestFeedbacks(String feedbackTitle, String feedbackContent) {
            this.mFeedbackTitle = feedbackTitle;
            this.mFeedbackContent = feedbackContent;
        }

        @Override
        public Map<String, Object> getPostNetParams() {
            Map<String, Object> map = new HashMap<String, Object>();
            map.put("feedback[title]", mFeedbackTitle);
            map.put("feedback[content]", mFeedbackContent);
            return map;
        }

        @Override
        public Map<String, Object> getHeaderNetParams() {
            return getHeader();
        }

        @Override
        public String getUrl() {
            return String.format(SUFFIX_URL);
        }
    }

    /**
     * 搜索（POST）
     */
    public static class RequestSearch implements NetUtil.NetParams {
        /**
         * http://42.121.104.18:10002/app/searches/list
         */
        public final static String SUFFIX_URL = API_HOST + "app/searches/list";
        private String mSearch;
        private long mLastTime;

        public RequestSearch(String search, long last_time) {
            this.mSearch = search;
            this.mLastTime = last_time;
        }

        public long getmLastTime() {
            return mLastTime;
        }

        @Override
        public Map<String, Object> getPostNetParams() {
            Map<String, Object> map = new HashMap<String, Object>();
            map.put("search", mSearch);
            map.put("last_time", mLastTime);
            return map;
        }

        @Override
        public Map<String, Object> getHeaderNetParams() {
            return getHeader();
        }

        @Override
        public String getUrl() {
            return String.format(SUFFIX_URL);
        }
    }

    /**
     * 解除绑定（POST）
     */
    public static class RequestUnBinding implements NetUtil.NetParams {
        /**
         * http://42.121.104.18:10002/app/users/remove_the_binding
         */
        public final static String SUFFIX_URL = API_HOST + "users/remove_the_binding";
        private int mSocialType;

        public RequestUnBinding(int socialType) {
            this.mSocialType = socialType;
        }

        @Override
        public Map<String, Object> getPostNetParams() {
            Map<String, Object> map = new HashMap<String, Object>();
            map.put("type", mSocialType);
            return map;
        }

        @Override
        public Map<String, Object> getHeaderNetParams() {
            return getHeader();
        }

        @Override
        public String getUrl() {
            return String.format(SUFFIX_URL);
        }
    }

    /**
     * Mob问卷点赞（POST）
     */
    public static class RequestMobLiked implements NetUtil.NetParams {
        /**
         * http://42.121.104.18:10002/app/options/mob_create_praise
         */
        public final static String SUFFIX_URL = API_HOST + "app/options/mob_create_praise";
        private int optionId;
        private int genre;

        public RequestMobLiked(int optionId, int genre) {
            this.optionId = optionId;
            this.genre = genre;
        }

        public int getOptionId() {
            return optionId;
        }

        public void setOptionId(int optionId) {
            this.optionId = optionId;
        }

        public int getGenre() {
            return genre;
        }

        public void setGenre(int genre) {
            this.genre = genre;
        }

        @Override
        public Map<String, Object> getPostNetParams() {
            Map<String, Object> map = new HashMap<String, Object>();
            map.put("genre", genre);
            map.put("option_id", optionId);
            return map;
        }

        @Override
        public Map<String, Object> getHeaderNetParams() {
            return getHeader();
        }

        @Override
        public String getUrl() {
            return String.format(SUFFIX_URL);
        }
    }

    /**
     * 普通问卷提交选项（POST）
     */
    public static class RequestSubmitOptions implements NetUtil.NetParams {
        /**
         * http://42.121.104.18:10002/app/papers/done
         */
        public final static String SUFFIX_URL = API_HOST + "app/papers/done";
        private int mPaperId;
        private String mOptions;

        public RequestSubmitOptions(int paper_id, String options) {
            this.mPaperId = paper_id;
            this.mOptions = options;
        }

        @Override
        public Map<String, Object> getPostNetParams() {
            Map<String, Object> map = new HashMap<String, Object>();
            map.put("paper_id", mPaperId);
            map.put("options", mOptions);
            return map;
        }

        @Override
        public Map<String, Object> getHeaderNetParams() {
            return getHeader();
        }

        @Override
        public String getUrl() {
            return String.format(SUFFIX_URL);
        }
    }

    private static Map<String, Object> getHeader() {
        Map<String, Object> map = new HashMap<>();
        map.put("Cookie", mCookie);
        return map;
    }

    /**
     * 我的收藏（POST）
     */
    public static class RequestMyFavorite implements NetUtil.NetParams {
        /**
         * http://42.121.104.18:10002/app/users/praises
         */
        public final static String SUFFIX_URL = API_HOST + "app/users/praises";
        private long mLastTime;

        public RequestMyFavorite(long last_time) {
            this.mLastTime = last_time;
        }

        public long getmLastTime() {
            return mLastTime;
        }

        @Override
        public Map<String, Object> getPostNetParams() {
            Map<String, Object> map = new HashMap<String, Object>();
            map.put("last_time", mLastTime);
            return map;
        }

        @Override
        public Map<String, Object> getHeaderNetParams() {
            return getHeader();
        }

        @Override
        public String getUrl() {
            return String.format(SUFFIX_URL);
        }
    }

    /**
     * ******************************************************************************
     * 业务逻辑结束
     * ******************************************************************************
     */
}
